#include <iostream>
using namespace std;

const int MOD = 109;
int n, m;

int main()
{
    cin >> n >> m;

    long long ret = n;
    for (int i = 0; i < m - 1; i++)
    {
        ret = ret * (n - 1) % 109;
    }

    cout << ret << endl;

    return 0;
}